import requests
from config import url, headers_web,headers_wechat


class LearningMaterials:

    def __int__(self):
        self.url = url
        self.headers = headers_web
        self.headers = headers_wechat

    @classmethod
    def post_learningmaterials(cls, url: str, params=None, headers=headers_web, json=None):
        """
        @Summary:新增学习材料
        @Description:老师端新增学习材料
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        """
        url = url + "/teachingApi/learningmaterials"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r
    @classmethod
    def post_publish(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:立即公开学习材料
        @Description:web端学习材料立即公开
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/publish"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_studentlearning(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:学生学习学习材料时长写入接口
        @Description:学生学习学习材料时长写入接口
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/studentlearning"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r


    @classmethod
    def post_materials_del(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:删除学习材料信息
        @Description:web端删除学习材料信息
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/del"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_materitals_modify(cls,url:str, params =None,headers= headers_web, json= None,paramspath= None):
        '''
        @Summary:修改学习材料信息
        @Description:1.web端修改学习材料信息
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath:
        :return:
        '''
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}"
        r = requests.post(url= url, params= params, headers= headers, json= json)
        return r

    @classmethod
    def post_pptmateritals(cls,url: str,params =None,headers = headers_web,json =None):
        '''
        @Summary:发布ppt文件到学习材料
        @Description:1.web端修改学习材料信息
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        '''
        url = url + "/teachingApi/v1/learningmaterials/releasepptlearningmaterials"
        r = requests.post(url = url,headers=headers,json= json,params=params)
        return r

    @classmethod
    def post_studentfinishlearning(cls,url: str,params =None,headers = headers_web,json =None,paramspath =None):
        '''
        @Summary:学生学习学习材料学习完成接口
        @Description:1.学生学习学习材料学习完成接口
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        '''
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/studentfinishlearning"
        r = requests.post(url = url,headers=headers,json= json,params=params)
        return  r


    @classmethod
    def get_learningmaterials_detail(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:获取学习材料详细信息
        @Description:web端根据id获取学习材料详细信息
        :param url:
        :param params:
        :param headers:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_studentstudy(cls, url: str, params=None, headers=headers_web,paramspath=None):
        """
        @Summary:老师查看学生学习学习材料列表
        @Description:老师查看学生学习学习材料列表
        :param url:
        :param params:
        :param headers:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/students"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_learningmaterials(cls, url: str, params=None, headers=headers_wechat,paramspath=None):
        '''
        @Summary:查询学习材料相关列表
        @Description:1.小程序学生端
        :param url:
        :param params:
        :param headers:
        :param paramspath:
        :return:
        '''
        url = url + f"/teachingApi/learningmaterials/{paramspath}/learningmaterials"
        r = requests.get(url= url, params= params, headers= headers)
        return r

    @classmethod
    def get_LearningNum(cls,url: str, params=None, headers=headers_web,paramspath=None):
        '''
        @Summary:学生学习材料人数统计
        @Description:1.学生学习材料人数统计
        :param url:
        :param params:
        :param headers:
        :param paramspath:
        :return:
        '''
        url = url + f"/teachingApi/v1/learningmaterials/{paramspath}/statisticsLearningNum"
        r = requests.get(url= url, params= params, headers= headers)
        return  r

    @classmethod
    def get_coursestatistics(cls,url: str, params=None, headers=headers_web):
        '''
        @Summary:课程学习材料统计接口
        @Description:1.大数据平台-课程学习材料总数排行榜使用
        :param url:
        :param params:
        :param headers:
        :return:
        '''
        url = url + "/teachingApi/learningmaterials/course/statistics"
        r = requests.get(url= url, params= params,headers=headers)
        return r

    @classmethod
    def get_materialslist(cls,url: str, params=None, headers=headers_wechat,paramspath=None):
        '''
        @Summary:查询学习材料相关列表
        @Description:1.小程序老师端
        :param url:
        :param params:
        :param headers:
        :param paramspath:
        :return:
        '''
        url = url + f"/teachingApi/learningmaterials/{paramspath}"
        r = requests.get(url= url,params= params, headers=headers)
        return r